<?php 


// 角色类
class Role
{
	function cat()
	{
		echo '我在吃饭 <br />';
	}
}
// 技能类

class Jinen
{
	function jianqi()
	{
		echo '发出剑气 <br />';
	}
}
// 工厂类
class Factory
{
	static function createHero($type)
	{
		switch ($type) {
			case 'role':
				return new Role();
				break;

			case 'jinen':
				return new Jinen();
				break;
		}
	}
	
}

$role = Factory::createHero('role');
$jinen = Factory::createHero('jinen');

$role->cat();
$jinen->jianqi();